package cn.pomit.springbootwork.zkserver.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.pomit.springbootwork.zkserver.model.IpModel;
import cn.pomit.springbootwork.zkserver.model.ResultModel;
import cn.pomit.springbootwork.zkserver.util.IPUtil;

@RestController
@RequestMapping("/zkServer")
public class ZkServerRest {

	@RequestMapping(value = "/ip", method = { RequestMethod.GET })
	public ResultModel welCome(HttpServletRequest request) {
		IpModel ipModel = new IpModel();
		ipModel.setClientIpAddress(IPUtil.getIpAddr(request));
		ipModel.setServerIpAddress(IPUtil.localIp());
		return ResultModel.ok(ipModel);
	}
}
